package com.houtai.eduservice.controller.front;

import com.houtai.commonutils.Result;
import com.houtai.eduservice.entity.StuRead;
import com.houtai.eduservice.entity.frontvo.ReadFrontVo;
import com.houtai.eduservice.service.StuReadService;
import com.houtai.servicebase.exceptionhandler.DException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @ClassName ReadFrontController
 * @Description 绘本接口
 * @Author xst
 * @Date 2022/12/17 23:13
 * @Version 1.0
 **/
@RestController
@RequestMapping("/eduservice/readfront")
@CrossOrigin
public class ReadFrontController {

    @Autowired
    private StuReadService readService;

    /**
     * 获取绘本详情
     * @param id
     * @return
     */
    @GetMapping("getRead/{id}")
    public Result getReadCover(@Valid @PathVariable Integer id){
        StuRead read= readService.getById(id);
        return Result.ok().data("read",read);
    }
    /**
     * xst
     * 根据绘本id获取oss地址
     */
    @GetMapping("getReadAuth/{id}")
    public Result getReadAuth(@Valid @PathVariable Integer id) {
        String url = readService.getUrl(id);
        return Result.ok().data("url",url);
    }
}
